package com.lijun.SpringBootJavaFX.controller;

import com.lijun.SpringBootJavaFX.model.person.People;
import de.felixroske.jfxsupport.FXMLController;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;


@FXMLController
public class MyController {

    @FXML
    ToggleGroup gender;
    @FXML
    TextField name;
    @FXML
    DatePicker birthday;

    @FXML
    AnchorPane anchorPane;


    @FXML
    private TableView<People> personTable;

    public void addDateToTable(ActionEvent actionEvent){
        String genderName = ((RadioButton)gender.getSelectedToggle()).getText();
        String genderValueStr = (String) ((RadioButton)gender.getSelectedToggle()).getUserData();
        int genderValue = Integer.parseInt(genderValueStr);
//        PersonVo person = new PersonVo(name.getText(),genderName,genderValue,birthday.getValue());
//        personTable.getItems().add(person);
//        name.clear();
//        birthday.setValue(null);
    }

    public void windowClose(ActionEvent actionEvent){
        Stage primaryStage = (Stage) anchorPane.getScene().getWindow();
        primaryStage.close();
    }

    public void windowMin(ActionEvent actionEvent){
        Stage primaryStage = (Stage) anchorPane.getScene().getWindow();
        primaryStage.setIconified(true);
    }

    public void windowMax(ActionEvent actionEvent){
        Stage primaryStage = (Stage) anchorPane.getScene().getWindow();
        primaryStage.setMaximized(!primaryStage.isMaximized());
    }
}
